#include "stm32f10x.h"                  // Device header
#include "Delay.h"
#include "Motor.h"
#include "OLED.h"
#include "Usart.h"
#include "LED.h"
#include "String.h"

int main(void)
{
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	OLED_Init();
	Usart1_Init();
	LED_Init();
	Motor_Init();
	
	while(1)
	{		
		Usart1_SendByte(0x01);
		Delay_ms(1000);
		
		if (Usart1_GetRxFlag())
		{
			if (strcmp(Rx_Packet,"CAR_F") == 0)
			{
				Car_Forward(200);
			}
			else if (strcmp(Rx_Packet,"CAR_B") == 0)
			{
				Car_Backward(200);
			}
			else if (strcmp(Rx_Packet,"CAR_TF") == 0)
			{
				Car_TurnLeft(200);
			}
			else if (strcmp(Rx_Packet,"CAR_TR") == 0)
			{
				Car_TurnRight(200);
			}
			else if (strcmp(Rx_Packet,"CAR_TSF") == 0)
			{
				Car_TransLeft(200);
			}
			else if (strcmp(Rx_Packet,"CAR_TSR") == 0)
			{
				Car_TransRight(200);
			}
			else
			{
				Car_Stop();
			}
		}
	}
}


